package vn.edu.uit.game_show;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;

public class NhomChuKyAdapter extends BaseAdapter{
	
	String[] nhom = {"IA", "IIA", "IIIA", "IVA", "VA", "VIA", "VIIA", "VIIIA"};
	String[] chuKy = {"2", "3", "4", "5"};
	
	boolean isNhom = true;
	private LayoutInflater inflater;
	Context context;
	
	
	public NhomChuKyAdapter(Context ctx, boolean isNhom) {
		this.context = ctx;
		inflater = LayoutInflater.from(ctx);
		this.isNhom = isNhom;
		
	}

	public int getCount() {
		if (!this.isNhom) {
			return chuKy.length;
		}
		return nhom.length;
	}

	public Object getItem(int pos) {
		return null;
	}

	public long getItemId(int pos) {
		return 0;
	}

	public View getView(int pos, View v, ViewGroup viewGroup) {
		
		ItemNhomChuKy holder;
		
		if (isNhom) {
			if (v == null) {
				v = inflater.inflate(R.layout.nhom_chuki_item, null);
				v.setLayoutParams(new GridView.LayoutParams(55, 16));
				holder = new ItemNhomChuKy();
				holder.nhomChuKy = (TextView) v.findViewById(R.id.tvNhom_ChuKi);
				v.setTag(holder);				
			} else {
				holder = (ItemNhomChuKy) v.getTag();
			}
			
			holder.nhomChuKy.setText(nhom[pos]);
			holder.nhomChuKy.setTextSize(13);
			holder.nhomChuKy.setGravity(Gravity.CENTER_HORIZONTAL);			
		} else {
			if (v == null) {
				v = inflater.inflate(R.layout.nhom_chuki_item, null);
				v.setLayoutParams(new GridView.LayoutParams(20, 45));
				holder = new ItemNhomChuKy();
				holder.nhomChuKy = (TextView) v.findViewById(R.id.tvNhom_ChuKi);
				holder.nhomChuKy.setGravity(Gravity.CENTER_HORIZONTAL);
				holder.nhomChuKy.setPadding(0, 5, 0, 0);
				holder.nhomChuKy.setTextSize(13);
				
				v.setTag(holder);				
			} else {
				holder = (ItemNhomChuKy) v.getTag();
			}
			
			holder.nhomChuKy.setText(chuKy[pos]);
		}
		v.setEnabled(false);
		return v;
	}
	
	public class ItemNhomChuKy {
		public TextView nhomChuKy;
	}

}
